<?php
// 这是系统自动生成的公共文件


use think\facade\Db;

function getMenuArr()
{
    $menuArr = include app_path() . 'config/menu.php';
    $act_list = session('act_list');
    if ($act_list != 'all' && !empty($act_list)) {
        $right = Db::name('system_menu')->where("id in ($act_list)")->getField('right', true);
        $role_right = '';
        foreach ($right as $val) {
            $role_right .= $val . ',';
        }
        foreach ($menuArr as $k => $val) {
            foreach ($val['child'] as $j => $v) {
                foreach ($v['child'] as $s => $son) {
                    if (strpos($role_right, $son['op'] . '@' . $son['act']) === false) {
                        unset($menuArr[$k]['child'][$j]['child'][$s]);//过滤菜单
                    }
                }
            }
        }
        foreach ($menuArr as $mk => $mr) {
            foreach ($mr['child'] as $nk => $nrr) {
                if (empty($nrr['child'])) {
                    unset($menuArr[$mk]['child'][$nk]);
                }
            }
        }
    }
    return $menuArr;
}
function getStoreInfo($store_id){

    return \app\admin\model\Store::where(['id'=>$store_id])->find();
}

function getBaseUsers($mobile){

    return \app\admin\model\member\BaseUsers::where(['mobile'=>$mobile])->find();
}

function getStoreAttrTpl($store_id): string
{
    $store_type=getStoreInfo($store_id)->store_type;

    switch ($store_type){

        case 1:
        default:
            $tpl='attr_car';
            break;

    }
    return $tpl;

}


